<?php
/*
Extension Name: Low-Cal Vanilla
Extension Url: http://lussumo.com/docs/
Description: Gunzip Vanilla pages.
Version: 0.1.1
Author: Dinoboff
Author Url: http://lussumo.com/community/account/2469/
*/

class LowCalVanilla extends Control {

	function Render() {
		// This is only defined if gunzip extension is installed
		if (defined('FORCE_GZIP')) {
			// Get the content of the page
			$content = ob_get_contents();
			ob_clean();
			// Create a new output handler inside the main one
			ob_start("ob_gzhandler");
			echo $content;
			// Flush the gunzip content into the main output handler
			// Allow to get ziped content length
			// http://www.php.net/manual/en/function.ob-get-length.php
			ob_end_flush();
			header('Content-Length: ' . ob_get_length());
		}
	}

	function LowCalVanilla(&$Context) {
		$this->Name = 'LowCalVanilla';
		$this->Control($Context);
	}
}

$LowCalVanilla = new LowCalVanilla($Context);
$Page->AddControl('Page_Unload', $LowCalVanilla);